//
//  JZHFriendsCircleViewController.m
//  极致荟
//
//  Created by mac on 14-4-8.
//  Copyright (c) 2014年 mac. All rights reserved.
//

#import "JZHFriendsCircleViewController.h"
#import "JZHPengyouCellTableViewCell.h"
#import "JZHPengYouContCell.h"
#import "JZHPersonaldetailsViewController.h"
#import "JZHAGViewController.h"
#import "JZHCEView.h"
#import "JZHSelectListViewController.h"
#import "JZHTabbarViewController.h"
#import "ImageCache.h"
#import "JZHPusMessgeViewController.h"
#import "JZHFocusType.h"
#import "JZHTheDiary.h"

#import "JZHTableViewCell.h"
#import "JZHSelectPhotoView.h"
    
@interface JZHFriendsCircleViewController ()
{
    __block  JZHCEView *ceview;
    __block UIButton *leftButton;
    NSMutableArray *dataarr;
    NSMutableArray *tjdata;
    
    JZHSelectPhotoView *selectPhotoView;
    
    //评论部分的信息
    JZHTheDiary *m_commentDiary;      //要评论的cell的JZHTheDiary
    NSString *strCommentContent;
    
    UIScrollView *fullScreenView;
    
    UIView *viewReceiveAddress;
    UITextView *txtAddress;
}

@property (strong, nonatomic) IBOutlet UIImageView *myHaedImage;
@property (weak, nonatomic) IBOutlet UIPageControl *page;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) IBOutlet UIView *headerView;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *company;



@end

@implementation JZHFriendsCircleViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [leftButton setSelected:NO];
    [ceview remove];
    [ceview right];
    
    //用于启动焦点，让键盘弹起来
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
//     addObserver:self selector:@selector(keyboardWillChange:)  object:nil];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self httploaddata];
    [[JZHTabbarViewController shareInstance] showTabBar2];
    
    NSArray *arr=[[NSArray alloc]initWithObjects:@"新鲜人脉",@"行业筛选",@"职业筛选",@"同城附近",@"地区筛选", nil];
    ceview= [[JZHCEView alloc]initarr:arr viewConetroller:[JZHTabbarViewController shareInstance]TopviewStype:1];
    ceview.topview.hidden=YES;
    ///侧边栏回调
    __block UIViewController *controller=self;
    ceview.pusblock=^(int i){
        JZHFocusType *ft=[JZHFocusType defulType:i+1];
        [UINavigationController Pus: controller  ToViewconeroller:[JZHSelectListViewController focusType:ft]];
    };
    
    ceview.rection=^(int i){
        if(i==1)
        {
            leftButton.selected=YES;
        }else
        {
            leftButton.selected=NO;
        }
    };
    
    //用于启动焦点，让键盘弹起来
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillChange:) name:UIKeyboardWillChangeFrameNotification object:nil];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.tableView.tableHeaderView = self.headerView;
    dataarr =[[NSMutableArray alloc]init];
    tjdata =[[NSMutableArray alloc]init];
    // Do any additional setup after loading the view from its nib.
   
    [_ag setContentOffset:CGPointMake(0, 0) animated:NO];
    [self setNavigation];
    [_myHaedImage.layer setBorderWidth:2];
    [_myHaedImage.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    [_myHaedImage.layer setCornerRadius:8];
    [_myHaedImage.layer setMasksToBounds:YES];
   
    [ImageCache imageUrl: [User defuceUser].userHeadImage  UiImageview: self.myHaedImage];
    
    self.name.text=[User defuceUser].name;
    [self setagscroll];
    [self vipiconimage];
    if(OSVersionIsAtLeastiOS7>=7.0)
    {
        self.automaticallyAdjustsScrollViewInsets=NO;
    }
    
    [self initInputView];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(disapperViewAction:)];
    tap.cancelsTouchesInView = NO;
    [self.tableView addGestureRecognizer:tap];
}


- (void)initInputView
{
    viewReceiveAddress = [[UIView alloc]initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - 44, [UIScreen mainScreen].bounds.size.width, 44)];
    [viewReceiveAddress setBackgroundColor:[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1]];
    [self.view addSubview:viewReceiveAddress];
    
    txtAddress = [[UITextView alloc]initWithFrame:CGRectMake(15, 5, 230, 34)];
    [txtAddress setBackgroundColor:[UIColor whiteColor]];
    [txtAddress.layer setCornerRadius:5];
    [txtAddress.layer setBorderColor:[UIColor colorWithRed:225/255.0 green:225/255.0 blue:225/255.0 alpha:1].CGColor];
    [txtAddress.layer setBorderWidth:0.5];
    [txtAddress setTag:8011];
    [viewReceiveAddress addSubview:txtAddress];
    
    UIButton *btnSure = [[UIButton alloc]initWithFrame:CGRectMake(txtAddress.frame.size.width + 25, 5, 60, 34)];
    [btnSure setTitle:@"确定" forState:UIControlStateNormal];
    [btnSure setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [btnSure.layer setBorderColor:[UIColor colorWithRed:225/255.0 green:225/255.0 blue:225/255.0 alpha:1].CGColor];
    [btnSure.layer setBorderWidth:0.5];
    [btnSure.layer setCornerRadius:5];
    [btnSure addTarget:self action:@selector(httpLoadDataComment:) forControlEvents:UIControlEventTouchUpInside];
    [viewReceiveAddress addSubview:btnSure];
    
    
}

- (void)keyboardWillChange:(NSNotification *)notification
{
    NSDictionary * info = [notification userInfo];
    NSValue *animationDurationValue = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
    NSTimeInterval animationDuration;
    [animationDurationValue getValue:&animationDuration];
    CGRect rect;
    rect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    
    NSDictionary *userInfo = notification.userInfo;
    UIViewAnimationCurve animationCurve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:animationDuration];
    [UIView setAnimationCurve:animationCurve];
    [UIView setAnimationBeginsFromCurrentState:NO];
    [viewReceiveAddress setFrame:CGRectMake(0, rect.origin.y - 44, 320, 44)];
    [UIView commitAnimations];
}

//会员图标显示设置
- (void)vipiconimage
{
    int vip=[User defuceUser].vip;
    if(vip==0)
    {
        if([User defuceUser].sex==1)
        {
            self.vipicon.image=[UIImage imageNamed:@"no1-1"];
        }else
        {
            self.vipicon.image=[UIImage imageNamed:@"no0-1"];
        }
        
        return;
    }
    
    if(vip==1)
    {
        self.vipicon.image=[UIImage imageNamed:@"vip1-1"];
    }else
    {
        self.vipicon.image=[UIImage imageNamed:@"vip2-1"];
    }
}
//导航条设置
-(void)setNavigation
{
    //设置导航视图title
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
    [titleLabel setTextColor:[UIColor blackColor]];
    [titleLabel setTextAlignment:NSTextAlignmentCenter];
    titleLabel.font = [UIFont boldSystemFontOfSize:16];
    titleLabel.text = @"朋友圈";
    self.navigationItem.titleView= titleLabel;
    
    //设置右侧导航按钮
    UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 44)];
    [rightButton addTarget:self action:@selector(rightDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
    [rightButton setImage:[UIImage imageNamed:@"friends_camera.png"] forState:UIControlStateNormal];
    UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = rightBarButton;
    
    //设置左侧按钮
    leftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 44)];
    [leftButton addTarget:self action:@selector(leftDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
    [leftButton setImage:[UIImage imageNamed:@"leftbar_item_bg.png"] forState:UIControlStateNormal];
    UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftBarButton;
    
  
}


- (void)leftDrawerButtonPress:(UIButton *)sender
{
    if(!sender.selected)
    {
        [ceview left];
        sender.selected=YES;

    }else
    {
        [ceview right];
        sender.selected=NO;

    }
}


- (void)swiperecogn:(UISwipeGestureRecognizer *)sw
{
    NSLog(@"%@",sw);
}
- (void)rightDrawerButtonPress:(UIButton *)sender
{
    selectPhotoView = [[JZHSelectPhotoView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    [selectPhotoView setDelegate:self];
    [self.view.window addSubview:selectPhotoView];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(touchTap:)];
    [selectPhotoView addGestureRecognizer:tap];
    
//    //调用照相或相册
//    UIActionSheet *actionshee=[[UIActionSheet alloc]initWithTitle:@"操作" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"照相" otherButtonTitles:@"相册", nil];
//    [actionshee showInView:[UIApplication sharedApplication].keyWindow];
    
//    [UINavigationController Pus:self ToViewconeroller:[JZHPersonaldetailsViewController shareName:@"我的相册"]];
}

///关闭相机相册视图
- (void)touchTap:(UITapGestureRecognizer *)tap
{
    [selectPhotoView removeSubView:^{
        [selectPhotoView removeFromSuperview];
    }];
}

- (IBAction)pusAg:(id)sender
{
    [UINavigationController Pus:self ToViewconeroller:[[JZHAGViewController alloc]init]];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)clikepus:(id)sender
{
    
    [UINavigationController Pus:self ToViewconeroller:[JZHPersonaldetailsViewController shareName:[User defuceUser]]];
    
}

- (void)httploaddata
{
    //[MMProgressHUD showWithStatus:@"数据加载中..."];
    NSDictionary *dic=[[NSDictionary alloc]initWithObjectsAndKeys:[NSNumber numberWithInt:[User defuceUser].userId],@"userId", @"friend_dynamic" ,@"relatedType", nil];
    [HttpRequest httpRequestPost:JZHHTTPURL(@"friendsDynamic/friendsDynamicList") parameters:dic block:^(id data, HttpReturnCode rerurncode) {
        if(rerurncode==0)
        {
            NSLog(@"%@",data);
            
            NSString *imageHead = [[data objectForKey:@"data"] objectForKey:@"imgPrefix"];
            [dataarr removeAllObjects];
            for(NSDictionary *datadic in [[data objectForKey:@"data"] objectForKey:@"list"])
            {
                JZHTheDiary *td=[[JZHTheDiary alloc]init];
                td.pathHead=[[data objectForKey:@"data"] objectForKey:@"imgPrefix"];
                td.tdDate=[NSDate dateWithTimeIntervalSince1970:[[datadic objectForKey:@"addTime"] longLongValue]];
                td.content=[datadic objectForKey:@"content"];
                td.arrCommentList = [datadic objectForKey:@"commentList"];
                td.arrPraiseList = [datadic objectForKey:@"praiseList"];
                //拼接图片地址
                NSArray *arrayImage = [[datadic objectForKey:@"fdImage"] allObjects];
                NSMutableArray *arrayNew = [NSMutableArray array];
                for (int i = 0; i < arrayImage.count; i++)
                {
                    NSString *strURL = [NSString stringWithFormat:@"%@%@",imageHead, [arrayImage objectAtIndex:i]];
                    [arrayNew addObject:strURL];
                }
                td.images = arrayNew;
                td.userId=[[datadic objectForKey:@"userId"] intValue];
                td.userHeadImage=[td.pathHead stringByAppendingString:[datadic objectForKey:@"userAvatar"]];
                td.name=[datadic objectForKey:@"userName"];
                td.tdid=[datadic objectForKey:@"id"];
                
                [dataarr addObject:td];
            }
            
            for(NSDictionary *tj in [[data objectForKey:@"data"] objectForKey:@"recommend"])
            {
                [tjdata removeAllObjects];
                OtherUsers *ouser=[[OtherUsers alloc]init];
                ouser.userId=[[tj objectForKey:@"userId"] intValue];
                ouser.userHeadImage=[[[data objectForKey:@"data"] objectForKey:@"imgPrefix"] stringByAppendingString:[tj objectForKey:@"userAvatar"]];
                ouser.name=[tj objectForKey:@"userName"];
                [tjdata addObject:ouser];
            }
            [self.tableView reloadData];
            
            //更新用户数据
            NSDictionary *dict = [[data objectForKey:@"data"]objectForKey:@"userInfo"];
            NSString *strCompany;
            if([dict objectForKey:@"company"]==[NSNull null])
            {
                strCompany=@"";
            }else
            {
                strCompany = [dict objectForKey:@"company"];

            }
            self.company.text = strCompany;
            
            [MMProgressHUD dismiss];
        }else
        {
            [MMProgressHUD  showInformationWithTips:@"数据加载失败"];
        }
    }];
}
- (void)setagscroll
{
    [_ag setContentSize:CGSizeMake(320*3, 0)];
    //[_page setNumberOfPages:3];
    _page.hidden=YES;
    for(int i=0;i<1;i++)
    {
        UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(i*320, 0, 320, 170)];
        //[ImageCache imageName:@"3.jpg" UiImageview:imageview];
        [imageview setImage:[UIImage imageNamed:@"activity_big_image"]];
        [_ag addSubview:imageview];
    }
   
}
#pragma mark-------TableView代理----------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

{
    return dataarr.count + 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row==0)
    {
        return 86;
    }
    else
    {
//        JZHPengYouContCell *cell=[[NSBundle mainBundle] loadNibNamed:@"JZHPengYouContCell" owner:self options:nil][0];
//       // NSLog(@"%f",[cell addCellData:dataarr[indexPath.row]]);
//        return [cell addCellData:dataarr[indexPath.row-1]];
        
        UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
        return cell.frame.size.height;
    }
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *pengyoucell=@"PengyouCell";
    
    if(indexPath.row == 0)
    {
        JZHPengyouCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:pengyoucell];
        if(!cell)
        {
            cell = [[[NSBundle mainBundle]loadNibNamed:@"JZHPengyouCellTableViewCell" owner:self options:nil] objectAtIndex:0];
            [cell setHaedImageList:tjdata];
            cell.viewcontroller = self;
        }
        
        return cell;
    }
    else
    {
//        JZHPengYouContCell *cell=[tableView dequeueReusableCellWithIdentifier:pengyoucell];
//        if(!cell)
//        {
//            cell=[[[NSBundle mainBundle] loadNibNamed:@"JZHPengYouContCell" owner:self options:nil] objectAtIndex:0];
//        }
//        [cell.headImage.layer setCornerRadius:6.0];
//        [cell.headImage.layer setMasksToBounds:YES];
//        [cell addCellData:dataarr[indexPath.row-1]];
        
        static NSString *strCell = @"friendCell";
        
        JZHTableViewCell *cell = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:strCell];
        
        if (nil == cell)
        {
            cell = [[JZHTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strCell];
            [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        }
        
        JZHTheDiary *diary = [dataarr objectAtIndex:indexPath.row - 1];
        float height = [cell setCellTopData:diary];
        
        [cell setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, height)];
        [cell setDelegate:self];
        [cell.contentView setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, height)];
        
        return cell;
    }
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    [UINavigationController Pus:self ToViewconeroller:[JZHPersonaldetailsViewController shareName:dataarr[indexPath.row-1]]];
}

#pragma mark----scorllview delete-----
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
{
 
    CGFloat x=scrollView.contentOffset.x/320;
    if(fmod (x,1 )==0)
    {
            [_page setCurrentPage:x];
    }

//    [[NSNotificationCenter defaultCenter] postNotificationName:@"closeZanAndComment" object:nil];
}

//#pragma mark actionsheet 代理方法实现-------------
//- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
//{
//    if(buttonIndex==1)//找一张
//    {
//        
//        if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
//            [[[UIAlertView alloc]initWithTitle:@"提示" message:@"当前相册不可用" delegate:Nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
//            return;
//        }
//        UIImagePickerController *imagecont=[[UIImagePickerController alloc]init];
//        imagecont.delegate=self;
//        
//        [self presentViewController:imagecont animated:YES completion:^{}];
//        
//    }else if (buttonIndex==0)//照一张
//    {
//        if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
//            [[[UIAlertView alloc]initWithTitle:@"提示" message:@"当前相机不可用" delegate:Nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
//            
//            return;
//        }
//        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
//        [imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
//        [imagePickerController setDelegate:self];
//        [imagePickerController setAllowsEditing:YES];
//        [self presentViewController:imagePickerController animated:YES completion:^{}];
//        
//        
//    }
//    
//}

#pragma mark 相册 代理方法实现-------------
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *img;
    if(picker.sourceType == UIImagePickerControllerSourceTypeCamera){
        img=[info objectForKey:UIImagePickerControllerEditedImage];
    }else {
        img=[info objectForKey:UIImagePickerControllerOriginalImage];
    }
    [self dismissViewControllerAnimated:NO completion:^{
    }];
    [self.navigationController pushViewController:[JZHPusMessgeViewController shareImage:img] animated:YES];
}

#pragma mark - 点击头像跳页
- (void)pushUserInfoVC:(User *)user
{
    JZHPersonaldetailsViewController *personaldetailsVC = [[JZHPersonaldetailsViewController alloc]init];
    personaldetailsVC.userID = [NSString stringWithFormat:@"%d",user.userId];
    personaldetailsVC.user = user;
    [UINavigationController Pus:self ToViewconeroller:personaldetailsVC];
}

#pragma mark -
#pragma mark 点赞和评论
//点赞
- (void)httpLoadDataZan:(NSString *)dynamicId
{
    NSString *strID = [NSString stringWithFormat:@"%d",[User defuceUser].userId];
    if (strID.length == 0)
    {
        return;
    }
    [MMProgressHUD showWithStatus:@"数据加载中..."];
    NSDictionary *dic=[[NSDictionary alloc]initWithObjectsAndKeys:[NSNumber numberWithInt:[User defuceUser].userId], @"userId", dynamicId, @"praiseId", @"friend_dynamic", @"praiseType", @"1", @"isPraise", nil];
    [HttpRequest httpRequestPost:JZHHTTPURL(@"friendsDynamic/addPraise") parameters:dic block:^(id data, HttpReturnCode rerurncode) {
        if(rerurncode==0)
        {
            [MMProgressHUD dismissWithSuccess:@"赞成功"];
        }
        else if(rerurncode == 4)
        {
            [MMProgressHUD dismissWithError:@"你已赞过"];
        }
        else
        {
            [MMProgressHUD dismissWithError:@"赞失败"];
        }
    }];
}

- (void)httpLoadDataComment:(UIButton *)sender
{
    NSString *strID = [NSString stringWithFormat:@"%d",[User defuceUser].userId];
    if (strID.length == 0)
    {
        return;
    }
    
    /*
     *commentId：评论的ID
     commentType：评论类型（(专题内容topic_content，聚会：party，活动：club，动态：friends_dynamic)）
     replyId：评论回复id
     content：评论内容
     */
    [MMProgressHUD showWithStatus:@"数据加载中..."];
    NSDictionary *dic=[[NSDictionary alloc]initWithObjectsAndKeys:[NSNumber numberWithInt:[User defuceUser].userId],@"userId", m_commentDiary.tdid, @"commentId", @"friend_dynamic", @"commentType", @"0", @"replyId", txtAddress.text, @"content", nil];
    [HttpRequest httpRequestPost:JZHHTTPURL(@"comment/addComment") parameters:dic block:^(id data, HttpReturnCode rerurncode) {
        if(rerurncode==0)
        {
            [txtAddress resignFirstResponder];
            [txtAddress setText:@""];
            
            [MMProgressHUD dismissWithSuccess:@"评论成功"];
        }
        else
        {
            [MMProgressHUD dismissWithError:@"评论失败"];
        }
    }];
}

#pragma mark-
#pragma mark--图片点击放大
/*
 *图片点击放大
 */
-(void)imageViewBig:(NSArray *)array andIndex:(NSString *)strIndex
{
    int index = [strIndex intValue];
    
    fullScreenView = [[UIScrollView alloc] initWithFrame:self.view.window.frame];
    [fullScreenView setContentSize:CGSizeMake([UIScreen mainScreen].bounds.size.width * array.count, [UIScreen mainScreen].bounds.size.height)];
    [fullScreenView setBackgroundColor:[UIColor blackColor]];
    [fullScreenView setPagingEnabled:YES];
    
    [self.view.window addSubview:fullScreenView];
    [fullScreenView setAlpha:0];
    [UIView animateWithDuration:0.2f animations:^{
        [fullScreenView setAlpha:1];
    } completion:^(BOOL finished) {
        [[UIApplication sharedApplication] setStatusBarHidden:YES];
        for(int i = 0; i < array.count; i++)
        {
            UIImageView *displayImgV = [[UIImageView alloc] initWithFrame:CGRectMake(i * [UIScreen mainScreen].bounds.size.width, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
            [displayImgV setBackgroundColor:[UIColor clearColor]];
            
            [displayImgV setContentMode:UIViewContentModeScaleAspectFit];
            [fullScreenView addSubview:displayImgV];
            
            UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
            [indicator setCenter:displayImgV.center];
            [displayImgV addSubview:indicator];
            [indicator startAnimating];
            
            [ImageCache imageUrl:[array objectAtIndex:i] UiImageview:displayImgV];
            
            [indicator stopAnimating];
            [indicator removeFromSuperview];
            
        }
        [fullScreenView setContentOffset:CGPointMake([UIScreen mainScreen].bounds.size.width * index, 0) animated:NO];
        UITapGestureRecognizer *lastTouch = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reduceImage:)];
        [fullScreenView addGestureRecognizer:lastTouch];
    }];
    
}

/*
 *图片缩小回到原位置
 */
- (void)reduceImage:(UITapGestureRecognizer *)aTapGestureRecognizer
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    
    [UIView animateWithDuration:0.2f animations:^{
        [fullScreenView setAlpha:0];
    } completion:^(BOOL finished) {
        
        [fullScreenView removeFromSuperview];
        fullScreenView = nil;
    }];
}


#pragma mark -
#pragma mark 评论弹键盘
UIView *viewBackground;
- (void)showCommentKeyboard:(JZHTheDiary *)diary
{
    m_commentDiary = diary;

    [txtAddress becomeFirstResponder];
}

- (void)disapperViewAction:(UITapGestureRecognizer *)tap
{
    [txtAddress resignFirstResponder];
    
//    [[NSNotificationCenter defaultCenter] postNotificationName:@"closeZanAndComment" object:nil];
}

@end
